package com.lzx.demo.bloodpressurehelper.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by admin on 2016/10/27.
 */
public class MyDBOpenHelper extends SQLiteOpenHelper {
    public MyDBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    /**
     * 首次使用软件时生成数据库表
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        /*
            创建血压表
         */
        createBloodPressureTable(db);
    }

    /**
     * 创建血压表
     * @param db
     * @return
     */
    public void createBloodPressureTable(SQLiteDatabase db){
        String sqlStr = "CREATE TABLE IF NOT EXISTS" +
                "   blood(" +
                "           ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                "           HEIGHT_BLOOD_PRESSURE INT," +
                "           LOW_BLOOD_PRESSURE INT," +
                "           HEART_RATE INT," +
                "           remem_time DATETIME )";
        db.execSQL(sqlStr);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
